/**
 * 类型别名
 *    作用：将现有类型做定义，取个别名，后面后续的复用
 *
 *    语法：type XXX = 类型
 */

// 1. 描述对象
type Person = {
  name: string;
  age: number;
};

let p1: Person = {
  name: "张三",
  age: 18,
};

let p2: Person;

// 2. 描述函数
type Callback = () => number;

function find(cb: Callback) {
  const num: number = cb();
}

// 3. 描述联合类型
type StringOrNumber = string | number;

// 4. 描述交叉类型
type StringAndNumber = string & number;

type Dongwu = {
  name: string;
  age: number;
};

type Cat = {
  color: string;
};

type CatDongwu = Dongwu & Cat;

let c1: CatDongwu = {
  name: "小麦",
  age: 19,
  color: "red",
};
